#!/usr/bin/env python
def run_in_docker(pycode1):
    import tarfile
    import docker
    import commands

    tar = tarfile.open("dockertar.tar", "w")
    tar.add(pycode1)
    tar.close()
    data = open("dockertar.tar").read()

    status, container_id = commands.getstatusoutput("docker run -d -i -t zwc/ubuntu17.04:v2 /bin/bash")
    client = docker.from_env()
    con = client.containers.get(container_id)
    con.put_archive('/root', data)
    ret = con.exec_run("python /root/"+pycode1)
    con.kill()

    return ret


